package com.yayan.xh.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapHandler;

public class ShopDao extends ConnectionBase implements IShopDao {

	private Connection conn = null;
	
	private QueryRunner qRunner = null;
	
	private PreparedStatement ps = null;
	
	private ResultSet rsKey = null;
	
	@Override
	public Map<String, Object> getShopByShopId(Map<String, String> map) throws Exception {
		Map<String, Object> result = null;
		try {
			qRunner = new QueryRunner();
			String sql = "select * from tb_shop where shop_id=?";
			conn = getConn();
			result = qRunner.query(conn, sql, new MapHandler(), map.get("shopId"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			close(conn, ps, rsKey);
		}
		return result;
	}

	@Override
	public Map<String, Object> getShopByCode(Map<String, String> map) throws Exception {
		Map<String, Object> result = null;
		try {
			qRunner = new QueryRunner();
			String sql = "select * from tb_shop where s_code=?";
			conn = getConn();
			result = qRunner.query(conn, sql, new MapHandler(), map.get("mchId"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			close(conn, ps, rsKey);
		}
		return result;
	}

}
